package com.gmstu.defaults.dao;

import com.gmstu.defaults.entity.Order;
import com.gmstu.springorm.common.jdbc.datasource.DynamicDataSource;
import com.gmstu.springorm.framework.BaseDaoSupport;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import javax.sql.DataSource;

/**
 * @author John.zhang
 * @version Id: OrderDao, v 1.0 2020/9/1 16:35 ZhiYong Exp $
 */
@Repository
public class OrderDao extends BaseDaoSupport<Order,Long> {

    private DynamicDataSource dataSource;

    @Override
    protected String getPKColumn() {
        return "id";
    }

    @Override
    @Resource(name="dynamicDataSource")
    protected void setDataSource(DataSource dataSource) {
        this.dataSource = (DynamicDataSource) dataSource;
        this.setDataSourceRead(dataSource);
        this.setDataSourceWrite(dataSource);
    }
}
